package com.zhilianbao.leyaogo.ui.fragment.me.myorder;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.bql.utils.EventManager;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.events.LeEventCode;
import com.zhilianbao.leyaogo.ui.fragment.base.BaseTabFragment;
import com.zhilianbao.leyaogo.utils.DataProviderUtils;

import java.util.ArrayList;

/**
 * Created by liu on 2016/10/25.
 * 我的订单
 */
public class MyOrderFragment extends BaseTabFragment {
    private static int num;
    private ArrayList<Fragment> mFragments = new ArrayList<>();

    public static MyOrderFragment getInstance(int num) {
        MyOrderFragment.num = num;
        MyOrderFragment fragment = new MyOrderFragment();
        return fragment;
    }

    @Override
    public String[] getTabTitles() {
        return DataProviderUtils.getMyOrderTabTitles();
    }

    @Override
    public ArrayList<Fragment> getFragments() {
        mFragments.add(AllFragment.getInstance());
        mFragments.add(WaitToPayFragment.getInstance());
        mFragments.add(WaitToSendFragment.getInstance());
        mFragments.add(SendingFragment.getInstance());
        mFragments.add(WaitToEvaluateFragment.getInstance());
        return mFragments;
    }

    @Override
    protected void initToolbarHere() {
        initToolbar(getString(R.string.my_order));
    }


    @Override
    protected void initViewsAndEvents(Bundle savedInstanceState) {
        mViewpager.setCurrentItem(num);
    }


    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_tab;
    }


    @Override
    public int getInitPageNum() {
        return 5;
    }


    @Override
    public boolean registerEventBus() {
        return true;
    }

    @Override
    protected void onHandleEvent(EventManager eventManager) {
        super.onHandleEvent(eventManager);
        switch (eventManager.getEventCode()) {
            case LeEventCode.MSG_CODE_PAY_FINISH:
                mActivity.finish();
                break;
        }
    }
}
